package main

import (
	"fmt"
	"math/rand"
	"time"
)

func main() {
	chan1 := make(chan int, 10)
	go send(chan1)
	for {
		value, ok := <-chan1
		if !ok {
			break
		}
		fmt.Println("receive a value:", value)
		time.Sleep(time.Second * 2)
	}
}

func send(ch chan int) {
	//rand.Seed(time.Now().UnixNano())
	for {
		num := rand.Intn(10)
		ch <- num
		time.Sleep(time.Second)
	}

}
